﻿using System;
using System.Collections.Generic;
using System.Collections;
using System.Linq;
using System.Text;
using SchemaGraph.Interfaces;
using SchemaGraph.Interfaces.Vertexes;
using SchemaGraph.Interfaces.Edges;
using SchemaGraph.Vertexes;
using ObjectGraph.Core;

namespace SchemaGraph
{
    public class VertexCollection : GraphBase.VertexCollection, IVertexCollection
    {
        Graph m_graph;

        public VertexCollection(GraphBase.OnVertexAdded added, GraphBase.OnVertexRemoved removed, Graph graph)
            : base ( added, removed )
        {
            m_graph = graph;
        }

        #region IVertexCollection Members

        public ISimpleTypeVertex CreateSimpleTypeVertex(string typeName)
        {
            SimpleTypeVertex retval = new SimpleTypeVertex(typeName);
            Construct(retval);
            return retval;
        }

        public IComplexTypeVertex CreateComplexTypeVertex(string typeName)
        {
            ComplexTypeVertex retval = new ComplexTypeVertex(typeName);
            Construct(retval);
            return retval;
        }

        #endregion

        private void Construct(GraphBase.Vertex vertex)
        {
            vertex.zzSetGraph(m_graph);
            base.Add(vertex);
        }
    }
}
